#include <iostream>
using namespace std;

int main() {
    int a, b;
    while (cin >> a >> b)
    {
        int m[13] = { 0, 31,28,31,30,31,30,31,31,30,31,30,31 };
        if ((a % 4 == 0 && a % 100 != 0) || a % 400 == 0)
        {
            m[2] = 29;
        }
        int i = 1;
        while (b > m[i])
        {
            b -= m[i];
            ++i;
        }
        printf("%d-%02d-%02d\n", a, i, b);
    }
}